<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
  		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>MES制造执行系统</title>
		<link rel="stylesheet" type="text/css" href="/admin/layui/css/layui.css"/>
		<link rel="stylesheet" type="text/css" href="/admin/css/admin.css"/>
	</head>
	<body>
		<div class="main-layout" id='main-layout'>
			<!--侧边栏-->
			<div class="main-layout-side">
				<div class="m-logo">
					<img src="../images/logo.png" class="m-logo layui-nav-img"/>
				</div>
				<ul id ="menuTree" class="layui-nav layui-nav-tree" lay-filter="leftNav">
				  <!--<li class="layui-nav-item ">-->
				    <!--<a href="javascript:;"><i class="iconfont">&#xe607;</i>系统管理</a>-->
				    <!--<dl class="layui-nav-child">-->
				      <!--<dd><a href="javascript:;" data-url="../index/user.html" data-id='1' data-text="用户管理"><span class="l-line"></span>用户管理</a></dd>-->
				      <!--<dd><a href="javascript:;" data-url="../index/role.html" data-id='2' data-text="角色管理"><span class="l-line"></span>角色管理</a></dd>-->
					  <!--<dd><a href="javascript:;" data-url="../index/privilege.html" data-id='3' data-text="权限管理"><span class="l-line"></span>权限管理</a></dd>-->
					<!--</dl>-->
				  <!--</li>-->
				  <!--<li class="layui-nav-item">-->
				    <!--<a href="javascript:;"><i class="iconfont">&#xe608;</i>工艺管理</a>-->
				    <!--<dl class="layui-nav-child">-->
				      <!--<dd><a href="javascript:;" data-url="../index/operation.html" data-id='4' data-text="操作管理"><span class="l-line"></span>步骤管理</a></dd>-->
				      <!--<dd><a href="javascript:;" data-url="../index/crafts.html" data-id='5' data-text="工艺管理"><span class="l-line"></span>工艺管理</a></dd>-->
				    <!--</dl>-->
				  <!--</li>-->
					<!--<li class="layui-nav-item">-->
						<!--<a href="javascript:;"><i class="iconfont">&#xe604;</i>物料管理</a>-->
						<!--<dl class="layui-nav-child">-->
							<!--<dd><a href="javascript:;" data-url="../index/materials.html" data-id='6' data-text="物料管理"><span class="l-line"></span>物料管理</a></dd>-->
						<!--</dl>-->
					<!--</li>-->
					<!--<li class="layui-nav-item">-->
						<!--<a href="javascript:;"><i class="iconfont">&#xe604;</i>计划管理</a>-->
						<!--<dl class="layui-nav-child">-->
							<!--<dd><a href="javascript:;" data-url="../index/plan.html" data-id='7' data-text="计划管理"><span class="l-line"></span>计划管理</a></dd>-->
						<!--</dl>-->
					<!--</li>-->
				  <!--<li class="layui-nav-item">-->
				    <!--<a href="javascript:;"><i class="iconfont">&#xe604;</i>生产管理</a>-->
					  <!--<dl class="layui-nav-child">-->
						  <!--<dd><a href="javascript:;" data-url="../index/product.html" data-id='8' data-text="生产管理"><span class="l-line"></span>生产管理</a></dd>-->
					  <!--</dl>-->
				  <!--</li>-->
					<!--<li class="layui-nav-item">-->
						<!--<a href="javascript:;"><i class="iconfont">&#xe604;</i>质量管理</a>-->
						<!--<dl class="layui-nav-child">-->
							<!--<dd><a href="javascript:;" data-url="../index/quality.html" data-id='9' data-text="质量管理"><span class="l-line"></span>质量管理</a></dd>-->
						<!--</dl>-->
					<!--</li>-->
				  <!--<li class="layui-nav-item">-->
				    <!--<a href="javascript:;" data-url="admin-info.html" data-id='10' data-text="个人信息"><i class="iconfont">&#xe606;</i>个人信息</a>-->
				  <!--</li>-->

				</ul>
			</div>
			<!--右侧内容-->
			<div class="main-layout-container">
				<!--头部-->
				<div class="main-layout-header">
					<div class="menu-btn" id="hideBtn">
						<a href="javascript:;">
							<span class="iconfont">&#xe60e;</span>
						</a>
					</div>
					<ul class="layui-nav" lay-filter="rightNav">
					  <!--<li class="layui-nav-item ">-->
					    <!--<a href="javascript:;" data-url="admin-info.html" data-id='5' data-text="个人信息">超级管理员</a>-->
					  <!--</li>-->
					  <li class="layui-nav-item"><a href="/admin/index/login.html">退出</a></li>
					</ul>
				</div>
				<!--主体内容-->
				<div class="main-layout-body">
					<!--tab 切换-->
					<div class="layui-tab layui-tab-brief main-layout-tab" lay-filter="tab" lay-allowClose="true">
					  <ul class="layui-tab-title">
					    <li class="layui-this welcome">后台主页</li>
					  </ul>
					  <div class="layui-tab-content">
					    <div class="layui-tab-item layui-show" style="background: #f5f5f5;">
					    	<!--1-->
					    	<iframe src="welcome.html" width="100%" height="100%" name="iframe" scrolling="auto" class="iframe" framborder="0"></iframe>
					    	<!--1end-->
					    </div>
					  </div>
					</div>
				</div>
			</div>
			<!--遮罩-->
			<div class="main-mask">
				
			</div>
		</div>
		<script type="text/javascript">
			var scope={
				link:'./welcome.html'
			}
		</script>
		<script src="../layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/common.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/main.js" type="text/javascript" charset="utf-8"></script>
		<script>
			layui.use('element', function() {
				var $ = layui.$;
				var element = layui.element;
				$.ajax({
					type: "get",
					url: "http://localhost:8080/privilege/getPrivilegesByUserId",
					error: function (XMLHttpRequest, textStatus, errorThrown) {
						alert("系统异常，请联系管理员!");
					},
					success: function (data) {
						var privigeData = data.data.userPriviligers;
						var parentPrivilges = privigeData.privileges;
						var childPrivilges = privigeData.privilegeMap;
						var dataId = 0;
						for(var i = 0;i< parentPrivilges.length;i++){
							var text = '';
							if(parentPrivilges[i].url != null && parentPrivilges[i].url != ""){
								text = ' <li class="layui-nav-item"><a href="javascript:;" '
										+ 'data-url="'+parentPrivilges[i].url+'" data-id=\''+(++dataId)+'\' data-text="'
										+parentPrivilges[i].privilegeName+'"><i class="iconfont">' + parentPrivilges[i].target + '</i>'+parentPrivilges[i].privilegeName+'</a>';
							}else {
								text = '\t<li class="layui-nav-item "><a href="javascript:;"><i class="iconfont">' + parentPrivilges[i].target + '</i>'
										+ parentPrivilges[i].privilegeName + '</a>\n';
							}
							if(childPrivilges[parentPrivilges[i].privilegeId] != null){
								var childPrivilgeList = childPrivilges[parentPrivilges[i].privilegeId];
								text = text + ' \t<dl class="layui-nav-child">';
								for(var j = 0; j<childPrivilgeList.length;j++){
									var childPrivilge = childPrivilgeList[j];
									text = text + '\t<dd><a href="javascript:;" data-url="'+childPrivilge.url +'" data-id= \''
											+ (++dataId) +'\' data-text=" '+childPrivilge.privilegeName+ '"><span class="l-line"></span>'
											+childPrivilge.privilegeName+'</a></dd>\n';
								}
								text = text + ' \t</dl>';
							}
							text = text + ' \t</li>';
							$('#menuTree').append(text);
							element.init();
						}
					}
				})
			})
		</script>
	</body>
</html>
